
* APPENDIX C - Don't Know Analyses

*  CSES (DON'T KNOW) TABLE

clear all	
cd "${data}"	
use "data1.dta", clear 


gen dk = .
replace dk = 0 if perception_dk_>=0 & perception_dk_<11
replace dk = 1 if perception_dk_==98
gen dk_daysafter = daysafter if dk ==1


eststo m_dk: mixed dk daysafter || country_: || election_: || respondent: 

cd "${tables}"	
esttab m_dk using tableC1.tex , replace ///
b(3) se(3) nogap transform(ln*: exp(2*@) 2*exp(2*@)) label mlabels ("Model 1")




* dk set at median

clear all	
cd "~/Dropbox/accuracy paper/march2024/data"	
use "data1.dta", clear 


gen IMD3007_median_=perception_dk_
sort election partyorder
by election partyorder: egen median_placement_=median(IMD3007_)
replace IMD3007_median_=median_placement_ if IMD3007_median_==98


gen observationlimit_CSES = . // in order to limit the bivariate model to the identical sample with the full model.
replace observationlimit_CSES = 1 if daysafter!=. & IMD5012_!=. & election_!=. & country_!=. & respondent!=. 


* bivariate model 1
eststo m0a_med: mixed IMD3007_median IMD5012_ if observationlimit_CSES==1 || country_: || election_: || respondent:

*base model
eststo m0b_med: mixed IMD3007_median daysafter IMD5012_ if observationlimit_CSES==1 || country_: || election_: || respondent: 

gen dk = .
replace dk = 0 if perception_dk_>=0 & perception_dk_<11
replace dk = 1 if perception_dk_==98
gen dk_daysafter = daysafter if dk ==1


eststo m1_med: mixed c.IMD3007_median c.daysafter##c.IMD5012_ || country_: || election_: || respondent: IMD5012_ 
margins, dydx(IMD5012_) at(daysafter=(0(30)300)) post
marginsplot, ///
    title("") ///
    ytitle("AME of a one-unit change in party position", size(3)) ///
    xtitle("days since election") ///
    xlabel(0(30)300, grid glpattern(solid) glcolor(gs14%50) glwidth(vthin)) ///
    ylabel(, grid glpattern(solid) glcolor(gs14%50) glwidth(vthin)) ///
    recast(line) plot1opts(color(gs12%50) lpattern(shortdash)) ///
    recastci(rarea) ciopt(color(gs12%50)) level(95) ///
    addplot(hist dk_daysafter, percent color(gs12%30) yaxis(2) ///
        ytitle("percent", size(3) axis(2)) ///
        yscale(range(0(5)50) axis(2) alt)) ///
		 legend(off) ///
    plotregion(lcolor(black) lwidth(thin) lpattern(solid))
	
		///
		plot1opts(lcolor(gs12) mcolor(gs12)) ///
    ciopts(lcolor(gs12) lwidth(thin)) ///


graph save "${figures}/figureC1.gph", replace
graph export "${figures}/figureC1.png", replace 



esttab m0a_med m0b_med m1_med using tableC2.tex , replace ///
b(3) se(3) nogap transform(ln*: exp(2*@) 2*exp(2*@))



*** BESIP ***


clear all	
cd "${data}"	
use "data2.dta", clear

keep if vague >2 & vague <8
	
xtset id vague

eststo m_DKoverall: xtreg overall_dk i.wave_, fe vce(cluster id)


margins, at(wave_=(3 4 5 6 7)) 
marginsplot, title("all parties") ytitle("") xtitle("") xlab(3/7, valuelabel labsize(small) angle(90)) xline(5,  lpattern("-.") lcolor(black))  yscale(range(0.16 (0.02) 0.24)) ylabel(#4, labsize(small))
graph save Graph ${figures}/figureC2.gph, replace


esttab m_DKoverall using ${data}/tableC3.tex , replace ///
b(3) se(3) nogap 


	
	 
